﻿using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace WzhModule.GM.UI
{
    public class WzhGMButton : Button
    {

        private int Id = -1;
        private bool Increase = false;
        private UnityAction<int> Action = null;
        private UnityAction<int, bool> ActionTwo = null;

        public void AddAction(UnityAction<int> action, int id)
        {
            Id = id;
            Action = action;
        }

        public void AddAction(UnityAction<int, bool> actionTwo, int id, bool increase)
        {
            Id = id;
            Increase = increase;
            ActionTwo = actionTwo;
        }

        public void Clear()
        {
            Id = -1;
            Action = null;
            onClick.RemoveAllListeners();
        }

        public override void OnPointerClick(PointerEventData eventData)
        {
            if (Action != null)
            {
                Action(Id);
                return;
            }
            if (ActionTwo != null)
            {
                ActionTwo(Id, Increase);
                return;
            }
            base.OnPointerClick(eventData);
        }
    }
}
